
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re;
import urllib.request;
from bs4 import BeautifulSoup

def getHtml():
    with open("device2.txt", "r",encoding='utf-8') as file:
        contents = file.read()  # 读取整个文件内容
        return contents

def get_content(url):
    html = urllib.request.urlopen(url);
    content = html.read();
    return content;

def getTitle():
    html = getHtml()
    soup=BeautifulSoup(html,"lxml")
    # print(soup)
    codes = soup.find_all('span',class_='p-card-name-title')
    for code in codes:
        print(code['title'])

# getTitle()

def getTitleByJd():
    html = getHtml()
    soup=BeautifulSoup(html,"lxml")
    codes = soup.find_all('div',class_='p-name p-name-type-2')
    # print(codes)
    for code in codes:
        print(code.em.text)

getTitleByJd()
